(*$T+,$F+*)

(*---------------------------------------------------------------*)
(*        EasyMenus 1.1 Alpha For Use With TDI Modula-2          *)
(*---------------------------------------------------------------*)
(* This is the Definition Module for Easy Menus.  All data       *)
(* structures are exported dequalified. To use these functions   *)
(* and data structures, just IMPORT them into your TDI Modula-2  *)
(* programs.                                                     *)
(*---------------------------------------------------------------*)
(* Copyright (c) Joe Pillera, June 1987.  All rights reserved.   *)
(*---------------------------------------------------------------*)

DEFINITION MODULE EasyMenus;

  FROM Strings IMPORT String;
  
  CONST
    NoKey = '#';       (* Menu item has no keyboard equivalent. *)
    Line  = "(----";   (* Menu item is only a line.             *)
 
  TYPE
    (* Use when calling the function "AppendToMenu".            *)
    MenuItemStyle  = (normal, bold, italic, underline, outline, shadow);
 
    (* Use when calling the functions SetMenuEnable and  *)
    (* SetItemEnable.                                    *)
    MenuEnableStatus = (enabled, disabled);
  
  (* Procedures *)
  (* Create a menu with title "MenuBarStr" at location MenuBar *)
  PROCEDURE  CreateMenu ( MenuBar     : INTEGER;
                          MenuBarStr  : String );
                          
  (* Insert an menu item "MenuItemStr" at menu number MenuBar. *)
  PROCEDURE  AppendToMenu ( MenuBar     : INTEGER;
                            MenuItemStr : String;
                            KeyEquiv    : CHAR;
                            Style       : MenuItemStyle );
  
  (* Enable or disable a particular menu item.                 *)
  PROCEDURE  SetItemEnable ( MenuBar  : INTEGER;
                             MenuItem : INTEGER;
                             Status   : MenuEnableStatus     );
  
  (* Enable or disable an ENTIRE menu bar.                     *)
  PROCEDURE  SetMenuEnable ( MenuBar : INTEGER;
                             Status  : MenuEnableStatus );
                                                
  (* Put/remove a check mark next to a menu item.              *)
  PROCEDURE CheckMenuItem ( MenuBar  : INTEGER;
                            MenuItem : INTEGER;
                            Checked  : BOOLEAN );
                        
  (* Update the menu bar after a menu creation or change.      *)
  PROCEDURE  UpdateMenuBar;
   
  (* Set up the Font Menu AUTOMATICALLY at the next menu bar!  *)
  PROCEDURE  SetUpFontMenu;
  
  (* Process a desk accessory call AUTOMATICALLY for the user. *)
  (* The value DAid is obtained from "MenuItem" when the       *)
  (* function UserEvent returns MenuBar = 1.                   *)
  PROCEDURE  HandleDA ( DAid : INTEGER );
  
  (* Process a Cut, Copy, Paste or Clear Clipboard request     *)
  (* AUTOMATICALLY for the user.  The value EditId is obtained *)
  (* from "MenuItem" when the function UserEvent returns the   *)
  (* value MenuBar = 3.                                        *)
  PROCEDURE  HandleEdit ( EditId : INTEGER );
  
  (* Implement the main event loop.  Look for both mouse-down  *)
  (* and key-down user requests.  If there was an event, set   *)
  (* the function to TRUE, and its formal parameters [MenuBar  *)
  (* and MenuItem] to the menu selection from the user         *)                                                
  PROCEDURE  UserEvent ( VAR MenuBar, MenuItem : INTEGER ) : BOOLEAN;
            
END EasyMenus.